package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.StatusEvent;
	import flash.net.LocalConnection;
	import flash.external.ExternalInterface;
	
	public class LoginComp extends Sprite
	{
		public function LoginComp()
		{
			if(stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			var obj:Object = this.loaderInfo.parameters;
			if(obj["channel"] == null) return;
			
			var channel:String = obj["channel"];
			var conn:LocalConnection = new LocalConnection();
			conn.addEventListener(StatusEvent.STATUS, onConnStatus);
			conn.send("_" + channel, "loginResult");
		}
		
		private function onConnStatus(evt:StatusEvent):void
		{
			if (ExternalInterface.available) ExternalInterface.call("window.close");
		}
		
	}
}